﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Projet_Synthese
{
    public class Partie
    {
        private int idPartie = 0;
        public static float AngleRatation = 0.10f;
        
        public String Nom { get; set; }
        public List<Tangram> Tangrams { get; set; }
        public String ImageFond { get; set; }
        public String EffetDeposé { get; set; }
        public String Ambiance { get; set; }
        public string EffetTerminé { get; set; }

        public Partie()
        {
            Tangrams = new List<Tangram>();
        }
        private void initialisation()
        {
            
            Nom = String.Empty;
            ImageFond = String.Empty;
            EffetDeposé = String.Empty;
            Ambiance = String.Empty;
            EffetTerminé = String.Empty;
        }
        public Partie(List<Tangram> tangrams, String nom)
        {
            Tangrams = tangrams;
            Nom = nom;
        }
        public bool Delete()
        {
            if (Count < 2)
                return false;
            Tangrams.RemoveAt(idPartie);
            if (idPartie == Tangrams.Count)
                idPartie--;
            return true;
        }
       
        public Tangram Tangram
        {
            get
            {
                if (idPartie < 0 | idPartie >= Tangrams.Count)
                    return null;
                return Tangrams[idPartie];
            }
            set
            {
                if (idPartie == Tangrams.Count)
                    Tangrams.Add(value);
                else if (idPartie > 0 | idPartie < Tangrams.Count)
                    Tangrams[idPartie] = value;
            }
        }
        public bool Next
        {
            get
            {
                if (Tangram != null && Tangram.EstComplete)
                    idPartie++;
                return idPartie < Tangrams.Count;
            }
        }
        public bool Prev
        {
            get
            {
                if (Tangram != null && Tangram.EstComplete)
                    idPartie--;
                return idPartie > 1;
            }
        }
        public bool IsFinish
        {
            get
            {
                return idPartie >= Tangrams.Count;
            }
        }
        public bool MoveNext()
        {
            if (Tangrams.Count > (idPartie+1))
            {
                idPartie++;
                return true;
            }
            return false;
        }
        public int IndexID { get { return idPartie; } }
        public int Count 
        { 
            get 
            { 
                if(Tangrams!=null)
                    return Tangrams.Count;
                return 0;
            } 
        }
        public bool MovePrev()
        {
            if (idPartie > 0)
            {
                if (Tangram.EstComplete)
                    Tangram.Reinitialisation();
                idPartie--;
                return true;
            }
            return false;
        }
        public void Rinitialiser()
        {
            for (int i = 0; i < Tangrams.Count; i++)
                Tangrams[i].Reinitialisation();
            idPartie = 0;
        }
    }
}
